//variables to move the fish
int tx, ty;

//a function to set up the general drawing parameters
void setup() {
  size(400, 200);
  background(#579D5F);
  smooth();
  tx = 400;
  ty = 100;
  frameRate(20);
}

//press any key to reset the fish
void keyPressed() {
  tx = 400;
  ty = 100;
}

//function to draw the fish
void drawFish() {
  fill(#8E8585); 
  stroke(0);
  ellipse(50, 50, 200, 90);
  triangle(185, 60, 200, -5, 128, 30);
  triangle(30, 10, 108, -40, 70, 10);
  stroke(255);
  fill(20);
  rect(1, 20, 20, 10);
}
  

//the draw function - which will loop
void draw() {
  
  background(#0422D8);
  
  //draw the fish in an updated position using variables
  pushMatrix();
  translate(tx, ty);
  drawFish();
  popMatrix();
  
  //update my variables - either randomly update y or use sin
  tx = tx - 1;
  //ty = ty + int(random(-5, 5));
  ty = 100 + int(30*sin(tx/400.0*6*PI));
}